clear all
set more off

// Run anaylsis at regional level

global input "...\replication\data"

use "$input\commute_reg_2013_2018.dta", clear

gen post = (year>=2016)

gen sample = 0
** Control 1 is Britany/Pays de la Loire
replace sample = 1 if REGION == "52" & REGLT == "53"
replace sample = 1 if REGION == "53" & REGLT == "52"
** Control 2 is old regional borders
replace sample = 2 if REGION != REGLT & sample != 1
** Treatment 
replace sample = 3 if REGION == REGLT
gen treat = (sample == 3)

drop if REGLT == "ZZ"
drop if REGLT == "1B"
destring REGION REGLT old_reg_res, replace

** Anylysis 1: Compare pre-post across regions
reg IPONDI treat 1.treat#1.post i.year if (sample == 1 | sample == 3), r
est store ATE_1
reg IPONDI treat 1.treat#1.post i.year i.REGION if (sample == 1 | sample == 3), r
est store ATE_2
reg IPONDI treat 1.treat#1.post i.year i.old_reg_res if (sample == 1 | sample == 3), r
est store ATE_3
reghdfe IPONDI 1.treat#1.post i.year if (sample == 1 | sample == 3), absorb(COMMUNE)
est store ATE_4

****************** Results in Table ******************
esttab ATE_1 ATE_2 ATE_3 ATE_4, ///
b(%9.3f) se(%9.3f) nolines nogaps star(* 0.10 ** 0.05 *** 0.01) ///
keep(treat 1.treat#1.post) stats(N r2)

